//
//  UIWindow+Shake.m
//  YHEduCustomer
//
//  Created by 米翊米 on 2018/5/23.
//  Copyright © 2018年 米翊米. All rights reserved.
//

#import "UIWindow+Shake.h"
#import "ServiceConfigVC.h"

#define ShakeMax    1

@implementation UIWindow (Shake)

- (BOOL)canBecomeFirstResponder {//默认是NO，所以得重写此方法，设成YES
    return YES;
}

- (BOOL)becomeFirstResponder {
    return NO;
}

- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    NSInteger shake = 0;
    if ([UserDefault objectForKey:@"shake"]) {
        shake = [[UserDefault objectForKey:@"shake"] integerValue];
    }
    [UserDefault setObject:@(shake+1) forKey:@"shake"];
    
    if (shake == ShakeMax) {
        ServiceConfigVC *vc = QZHInitXib(ServiceConfigVC);
        [[self getCurrentVC] presentViewController:[vc addNavigation] animated:YES completion:nil];
    }
}

@end
